package top.continew.admin.controller.specification;

import cn.shengchao.examstar.rpc.base.TransResult;
import cn.shengchao.examstar.rpc.product.api.ISpecificationTypeRpc;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotEmpty;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;
import top.continew.starter.web.model.R;

import java.util.List;

/**
 * @program: examstar-manger-api
 * @description: 课程大类调整
 * @author: Xiong weiqiang
 * @create: 2025-05-21 11:23
 */
@Tag(name = "规格类型管理 调整扩展API")
@RestController
@RequestMapping("/specTypeAdjust")
public class SpecificationTypeAdjustController {
    @DubboReference
    private ISpecificationTypeRpc specificationTypeRpc;
    @PostMapping("idSorts")
    @Operation(summary = "类目排序调整", description = "类目排序调整")
    public R<String> idSorts(@NotEmpty @RequestBody List<Long> specTypeIds) throws Exception {
        TransResult<String> transResult=  specificationTypeRpc.sortSpecificationTypesBySameLevelIds(specTypeIds);
        if (transResult.getSuccess()){
            return R.ok();
        }else {
            return R.fail(R.fail().getCode(),transResult.getMessage());
        }
    }
}